package com.ccp.dev.system.controller;

import com.ccp.dev.core.basic.internationalization.SysBaseController;
import com.ccp.dev.core.basic.consts.UrlConstants;
import com.ccp.dev.core.basic.util.ContextUtil;
import com.ccp.dev.core.basic.web.query.QueryFilter;
import com.ccp.dev.core.basic.util.UUIDUtils;
import com.ccp.dev.core.util.BeanUtils;
import com.ccp.dev.core.util.StringUtil;
import com.ccp.dev.core.util.RequestUtil;
import com.ccp.dev.system.model.SysUser;
import com.ccp.dev.system.model.SysWorkTimeSetting;
import com.ccp.dev.system.service.SysWorkTimeSettingService;
import com.ccp.dev.core.basic.annotion.Action;
import java.util.Date;
import java.util.List;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.ui.ModelMap;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;

/**
 * sys_worktime_setting 信息操作处理控制器
 * 
 * @author hw
 * @date 2019-10-15 14:32:52
 */
@Controller
@RequestMapping("/system/sysWorkTimeSetting")
public class SysWorkTimeSettingController extends SysBaseController{
	@Resource
	private SysWorkTimeSettingService sysWorkTimeSettingService;

    /**
     * 功能描述: 跳转到首页
     *
     * @return: java.lang.String
     * @auther: hw
     * @date: 2019-10-15 14:32:52
     */
    @RequestMapping(UrlConstants.VIEW_DISPATCH_PREFIX + UrlConstants.MODULE_FUNCTION_LIST)
    @Action(description="跳转到sys_worktime_setting首页")
    public String list() {
        return "sysWorkTimeSetting/list";
    }

    /**
     * 功能描述: 跳转到新增页面
     *
     * @return: java.lang.String
     * @auther: hw
     * @date: 2019-10-15 14:32:52
     */
    @RequestMapping(UrlConstants.VIEW_DISPATCH_PREFIX + UrlConstants.MODULE_FUNCTION_ADD_UPDATE)
    @Action(description="跳转到sys_worktime_setting新增页面")
    public String add(HttpServletRequest request,ModelMap modelMap) {
        String id = RequestUtil.getString(request,"id");
        modelMap.put("id",id);
        return "sysWorkTimeSetting/add";
    }

    /**
     * 功能描述:  数据保存通用方法
     *
     * @param: sysWorkTimeSetting 保存的对象
     * @return: java.lang.Object
     * @auther: hw
     * @date: 2019-10-15 14:32:52
     */
    @PostMapping(value = UrlConstants.MODULE_FUNCTION_SAVE, consumes = "application/json; charset=utf-8")
    @ResponseBody
    @Action(description="保存sys_worktime_setting数据")
    public Object save(@RequestBody SysWorkTimeSetting sysWorkTimeSetting) {
        int result = this.sysWorkTimeSettingService.save(sysWorkTimeSetting);
        return result > 0 ? getResultDataSuccess("save.success") : getResultDataError("save.failure");
    }

    /**
     * 功能描述: 根据主键ID删除数据的通用删除方法
     *
     * @param: id 参数名称必须是"id"
     * @return: java.lang.Object
     * @auther: hw
     * @date: 2019-10-15 14:32:52
     */
    @PostMapping(UrlConstants.MODULE_FUNCTION_DELETE)
    @ResponseBody
    @Action(description="根据主键ID删除sys_worktime_setting数据")
    public Object delete(@RequestParam("id") String id) {
        if (StringUtil.isEmpty(id)) {
            return fail("delete.failure.message");
        }
        int result = sysWorkTimeSettingService.delByIdArray(id.split(","));
        return result > 0 ? getResultDataSuccess("delete.success") : getResultDataError("delete.failure");
    }
    /**
     * 功能描述: 根据主键id获取一条数据的通用查询方法
     *
     * @param: id 参数对象必须是"id"
     * @return: java.lang.Object
     * @auther: hw
     * @date: 2019-10-15 14:32:52
     */
    @RequestMapping(UrlConstants.MODULE_FUNCTION_GET)
    @ResponseBody
    @Action(description="根据主键id查询sys_worktime_setting的一条数据")
    public Object get(@RequestParam("id") String id) {
        SysWorkTimeSetting sysWorkTimeSetting = null;
        if(StringUtil.isNotEmpty(id)){
            sysWorkTimeSetting = sysWorkTimeSettingService.geSettingDataById(id);
        }
        if (BeanUtils.isEmpty(sysWorkTimeSetting)) {
            return getResultDataError("get.failure");
        }
        return getResultDataSuccess("get.success",sysWorkTimeSetting);
    }

    /**
     * 功能描述: 附带检索条件的分页查询
     *
     * @param: [request] http请求
     * @return: java.lang.Object
     * @auther: hw
     * @date: 2019-10-15 14:32:52
     */
    @RequestMapping(UrlConstants.MODULE_FUNCTION_LIST)
    @ResponseBody
    @Action(description="附带检索条件的分页查询sys_worktime_setting")
    public Object list(HttpServletRequest request) {
        QueryFilter queryFilter = new QueryFilter(request, true);
        //分页数据
        List<SysWorkTimeSetting> pageDatas = sysWorkTimeSettingService.queryList(queryFilter);
        return success(pageDatas, queryFilter.getPageBean().getTotalCount());
    }


}
